;; ******** 字符集 ********
(set-language-environment "UTF-8")
(set-default-coding-systems 'utf-8)
(set-buffer-file-coding-system 'utf-8-unix)
(set-clipboard-coding-system 'utf-8-unix)
(set-file-name-coding-system 'utf-8-unix)
(set-keyboard-coding-system 'utf-8-unix)
(set-next-selection-coding-system 'utf-8-unix)
(set-selection-coding-system 'utf-8-unix)
(set-terminal-coding-system 'utf-8-unix)
(setq locale-coding-system 'utf-8)
(prefer-coding-system 'utf-8)

;; ******** 回答用y或n ********
(fset 'yes-or-no-p 'y-or-n-p)

;; ******** coding ********
(setq default-buffer-file-coding-system 'utf-8-unix)            ;; cache file
(setq default-file-name-coding-system 'utf-8-unix)              ;; file name
(setq default-keyboard-coding-system 'utf-8-unix)               ;; keyboard
(setq default-process-coding-system '(utf-8-unix . utf-8-unix)) ;; std
(setq default-sendmail-coding-system 'utf-8-unix)               ;; mail
(setq default-terminal-coding-system 'utf-8-unix)               ;; terminal

;; ******** delete selection mode ********
(delete-selection-mode 1) ;;当选择区域时，粘贴、插入等是先删除选区再操作

;; ******** 高亮显示要拷贝的区域 ********
(transient-mark-mode t)

;; ******** 显示时间 ********
(display-time)
(setq system-time-locale "C")

;; ******** tab用空格代替 ********
(setq-default indent-tabs-mode nil)

;; ******** misc functions ********
(defun now ()
  (interactive)
  (insert (current-time-string)))
(global-set-key (kbd "C-c n") 'now)

;; ******** 保存时删除行尾空白 ********
(add-hook 'before-save-hook 'delete-trailing-whitespace)

(provide 'init_misc)
